#include "reward.h"
#include"config.h"

reward::reward()
{
    //敌机资源加载
    m_reward.load(REWARD_PATH);

    //敌机位置
    m_X4=0;
    m_Y4=0;

    //敌机状态
    m_Free4=true;

    //敌机速度
    m_Speed4=REWARD_SPEED;

    //敌机矩形框（碰撞检测）
    m_Rect4.setWidth(m_reward.width());
    m_Rect4.setHeight(m_reward.height());
    m_Rect4.moveTo(m_X4,m_Y4);

}

void reward::updatePosition()
{
    //空闲状态敌机 不计算坐标
    if(m_Free4)
    {
        return;
    }

    m_X4-=m_Speed4;
    m_Rect4.moveTo(m_X4,m_Y4);

    //如果超出屏幕 重置空闲状态
    if(m_X4<-m_Rect4.width())
    {
        m_Free4=true;
    }
}
